package com.sino.cloud.api.repo;

import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import com.sino.cloud.api.domain.Swagger;

/**
 * Project: zhcore
 *
 * @Comments
 * @Author Zhong Han
 * @Created Date 2017/4/5
 */
@Component
public class SwaggerDocRepo {

	@Autowired
	RedisTemplate redisTemplate;

	/**
	 * @return
	 */
	public Set<Swagger> findAll() {
		return redisTemplate.keys("*");
	}

	/**
	 * @param basePath
	 * @return
	 */
	public Swagger findByBasePath(String basePath) {
		return (Swagger) redisTemplate.opsForValue().get(basePath);
	}

	/**
	 * @param swagger
	 */
	public void save(Swagger swagger) {
		redisTemplate.opsForValue().set(swagger.getBasePath(), swagger);
	}
}
